﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Diqu_Manage.aspx.cs" Inherits="Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.Diqu_Manage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="/Resources/xiaovcn/css/ssec-form.css"/>        
        <script type="text/javascript" src="/Resources/xiaovcn/scripts/common.js" ></script>
    <script type="text/javascript" src="/Resources/xiaovcn/scripts/usercheck.js"></script>
    <script type="text/javascript">

        function callback(res) {
            if (res.value) {
                $.messager.alert('提示', '操作成功！');
            }
            else {
                $.messager.alert('错误提示',res.error.Message);
            }
        }



        function save() {
            var a = $('#t1').val();
            var b = $('#t2').val();
            Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.Diqu_Manage.SaveDiqu(a, b, callback);
            clearForm();
            rebindgrid();
        }

        function del(model) {
            Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.Diqu_Manage.DeleteDiqu(model.DQBM, callback);
            rebindgrid();
        }

        function rebindgrid() {
            bindgrid();
            $('#add').window('close');
        }
       

        function bindgrid() {
            $('#tt').datagrid({
                title: '地区列表',
                url: 'Json/diquforgrid.aspx',
                iconCls: 'icon-applicationgo',
                nowrap: true,
                rownumbers: true,
                animate: false,
                collapsible: false,
                singleSelect: true,
                remoteSort: false,
                columns: [[
                         { field: 'DQBM', title: '地区编码', width: 100, sortable: true, formatter: function (val, rec) { return unescape(val) } },
                         { field: 'DQMC', title: '地区名称', sortable: true, width: 100, formatter: function (val, rec) { return unescape(val) } }                         
                ]],
                toolbar: [{
                    text: '增加',
                    iconCls: 'icon-add',
                    handler: function () {
                        clearForm();
                        $('#add').window('open');
                        //$('#t1').removeAttr("disabled");
                        var newsid = Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.OGWell.Diqu_Manage.GetNewId().value;
                        $('#t1').val(newsid);
                    }
                }, '-', {
                    text: '编辑',
                    iconCls: 'icon-edit',
                    handler: function () {
                        editrow();
                        $('#t1').attr("disabled", "disabled");
                    }
                }, '-', {
                    text: '删除',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        var diqu = $('#tt').datagrid('getSelected');
                        if (diqu) {
                            $.messager.confirm('提示', '确定要删除【' + unescape(diqu.DQMC) + '】这个地区吗?', function (r) {
                                if (r) {
                                    del(diqu);
                                }
                            });
                        }
                    }
                }],
                onLoadSuccess: function () {
                    $('#mask').fadeOut();
                },
                onDblClickRow: function () {
                    editrow();
                }
            });
        }

        function editrow() {
            //编辑用户
            var diqu = $('#tt').datagrid('getSelected');
            if (diqu) {
                $('#t1').attr("disabled", "disabled");
                $('#add').window('open');
                $('#t1').attr('value', diqu.DQBM);
                $('#t2').attr('value', diqu.DQMC);
               
            }
            else {
                alert('请选中一个记录');
            }
        }

        $(function () {
            bindgrid();
        });        
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>      
     <script>
         $('#tt').css('height', userScreenHeight + 20);
    </script>
   <div id="add" class="easyui-window" closed="true" modal="true" title="地区信息" style="width:400px;">
       <div id="contents" class="ssec-form">
       <div class="ssec-group ssec-group-hasicon"><img src="/Resources/easyui-1.32/themes/icons/mini_add.png" alt=""/>地区信息</div>
       <table>
         <tr>
                <td><div class="ssec-label">地区编码：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t1" ClientIDMode="Static" runat="server" CssClass="ssec-text-field easyui-validatebox" Enabled="false"  data-options="required:true" ></asp:TextBox></div></td>             
           </tr> 
           <tr>
                <td><div class="ssec-label">地区名称：</div></td>
                <td><div class="ssec-text normal"><asp:TextBox ID="t2" ClientIDMode="Static" runat="server" CssClass="ssec-text-field easyui-validatebox"   data-options="required:true" ></asp:TextBox></div></td>             
           </tr> 
            </table>
       <div ><a  class="easyui-linkbutton"  onclick="save()" iconCls="icon-save">保存</a></div>
       </div>
       </div>
</asp:Content>
